package com.aerospace.dbmysql.modules.userInfo.service.impl;

import com.aerospace.dbmysql.modules.userInfo.dao.UserInfoDao;
import com.aerospace.dbmysql.modules.userInfo.entity.UserInfo;
import com.aerospace.dbmysql.modules.userInfo.service.UserInfoService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.SQLOutput;
import java.util.List;


@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    UserInfoDao userInfoDao;

    @Override
    public List<UserInfo> findUserInfo() {
        return userInfoDao.findUserInfo();
    }


    @Transactional
    @Override
    public int update() {
        UserInfo userInfo = new UserInfo();
        userInfo.setId("2");
        userInfo.setName("李四");
        int update = userInfoDao.update(userInfo);
        System.out.println("更新结果：" + update);

        //除数不能为0,此处会抛出一个运行时的异常，上一步的更新就会回滚
//        int a = 10/0;
        return update;
    }
}
